
import apis from '../../http/apis/apis'
export default {
    namespaced:'admins',
    state:{
        adminsData:[],
        total:''

    },
    actions:{
        //获取管理员
        async getAdmins(context,getData){
            const {data} = await apis.admins.getAdmins(getData)
            console.log(data.data);
            context.commit('changeAdminsData',data.data)
            console.log(context.state.total);
        },
        //修改普通管理员密码
        async updateAdminPassword(context,data){
            const {result} = await apis.admins.updateAdminPassword(data)

        },
        //冻结/解冻管理员
        async frozenAdmin(context,data){
            const {result} = await apis.admins.frozenAdmin(data)

        },
        //新增管理员
        async addNewAdmin(context,data){
            await apis.admins.addNewAdmin(data)
        }
    },
    mutations:{
        changeAdminsData(state,data){
            state.adminsData=data.result.filter(elem=>elem.power==2)
            console.log(state.adminsData);
            state.total=data.total-1
        },
    }
}